package com.gxuwz.medical.domain.user;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.gxuwz.medical.database.DbUtil;

public class UserBean {
    
     public User login(String userid, String pwd,String status) {
        //实例化一个用户对象
        User user =null;
        Connection conn = DbUtil.getConn();
        String sql = "select * from t_user where userid = ? and pwd = ? and status=?";
        try {
            PreparedStatement ps = conn.prepareStatement(sql);
            ps.setString(1, userid);
            ps.setString(2, pwd);
            ps.setString(3, status);
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {

            	user= new User();
                user.setUserid(rs.getString("userid"));
                user.setPwd(rs.getString("pwd"));
                user.setPwd(rs.getString("status"));
            }
            rs.close();
            ps.close();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            DbUtil.closeConn(conn);
        }

        return user;
    }
}
